classdef dotsAllRemoteObjectManagersTestable < dotsAllRemoteObjectManagers
    % Concrete subclass of dotsAllRemoteObjectManagers for testing.
    
    properties
        acknowledgePropertyChangeFunction;
    end
    
    methods (Access = private)
        function self = dotsAllRemoteObjectManagersTestable
            dotsTheMachineConfiguration.applySettingsToObject(self, true);
            self.initialize;
        end
    end
    
    methods (Access = protected)
        % Always use theMessenger's default ports.
        function configureSockets(self)
            self.theMessenger.closeSocket(self.serverSocket);
            self.theMessenger.closeSocket(self.clientSocket);
            self.serverSocket = self.theMessenger.openDefaultServerSocket;
            self.clientSocket = self.theMessenger.openDefaultClientSocket;
        end
        
        % Do transactions synchronously.
        function txn = requestTransaction(self, varargin)
            txn = self.requestTransaction@dotsAllRemoteObjectManagers( ...
                varargin{:});
            %disp('request:'),txn
        end
        
        function txn = closeTransaction(self, varargin)
            txn = self.closeTransaction@dotsAllRemoteObjectManagers( ...
                varargin{:});
            %disp('ack:'),txn
        end
        
        function txn = carryOutTransaction(self, varargin)
            txn = self.carryOutTransaction@dotsAllRemoteObjectManagers( ...
                varargin{:});
            %disp('carry out:'),txn
        end
    end
    
    methods
        function acknowledgePropertyChange(self, object, property)
            self.acknowledgePropertyChange@dotsAllObjectManagers( ...
                object, property);
            if ~isempty(self.acknowledgePropertyChangeFunction)
                feval(self.acknowledgePropertyChangeFunction, ...
                    object, property);
            end
        end
    end
    
    methods (Static)
        % Access the current instance.
        function obj = theObject
            persistent self
            if isempty(self) || ~isvalid(self)
                constructor = str2func(mfilename);
                self = feval(constructor);
            end
            obj = self;
        end
        
        % Restore the current instance to a fresh state.
        function reset(varargin)
            factory = str2func([mfilename, '.theObject']);
            self = feval(factory);
            self.set(varargin{:});
            self.initialize;
        end
        
        function g = gui
            self = dotsAllRemoteObjectManagersTestable.theObject;
            g = self.managedObjects.gui;
        end
    end
end